<!DOCTYPE HTML>
<html>
<head>
  <?php include("res/head.php"); ?>
</head>

<body>

<?php include("res/social.php"); ?>

<div class="menu">  
  <div class="container clearfix">

    <a href="/wow/"><div id="logo" class="grid_3">
      <img src="/images/demo_logo.png">
    </div></a>
    
    <div id="nav" class="grid_9 omega">
      <a href="#" class="pull-right cart" onClick="cart()"><img src="/images/cart.png" /></a>
      <ul class="navigation">
        <li data-slide="1" onclick="home()">Акция дня</li>
        <li data-slide="2" onmouseover="category()" onmouseout="leftCategory()" id="categories">Категории</li>
        <li data-slide="3">Помощь</li>
        <?php 
        if(!($session_name)) { 
          echo "<li id='singin' onclick=\"change_location('/wow/home/signin')\">Войти</li>";
        }
        else { 
          echo "<li id='singin' onclick=\"change_location('/wow/home/logout')\">Выйти</li>";
        }
        ?>
      </ul>
    </div>
  
  </div>

  <div class="categories-container" onmouseover="categories()" onmouseout="leftCategories()">
    <?php 
      foreach ($categories as $category) {
        ?> <a href="/wow/home/all/#<?php echo $category->id + 10?>"><div class="category"><?php echo $category->name ?> </div></a> <?php
      }
     ?>
     <a href="/wow/home/all/"><div class="category">Все </div></a>
  </div>

  <div class="cart-container"> 

    <div id="content" class="grid_12 relative-holder">
      <h1>Корзина пока пуста</h1>
    </div>
  
  </div>

</div>

<div class="deal-desc-container">
  <div class="container clearfix">
    <div class="grid_12">
      <h1 style="padding:20px 0 20px 0px;"><?php echo $adeal->title ?></h1>
    </div>

    <div class="grid_8">

      <div id="slideshow">
       <a href="<?php echo $adeal->img_url ?>" class="zoom"><img src="<?php echo $adeal->img_url ?>" class="deal-img"/></a>
      </div>

    </div>

    <div class="grid_4 omega">

      <h5>Скидка:</h5>
      <h3><?php echo $adeal->sale ?>%</h3>
      <h5 style="margin-top:20px;">Цена купона:</h5>
      <h2><?php echo $adeal->s_cost - ($adeal->i_cost / 100 * (100 - $adeal->sale))  ?> тг</h2>
      <h5 style="margin-top:20px;">Стоимость услуги(товара):</h5>
      <h3><?php echo $adeal->s_cost ?> тг (экономия <?php echo $adeal->i_cost - $adeal->s_cost ?> тг)</h3>

      <a href="" class="btn btn-big">Купить <b class="btn-arrow">→</b></a>

    </div>
  </div>
</div>

<div class="slide deal" id="slide3" data-slide="3" data-stellar-background-ratio="0.5">
  <div class="container clearfix">
  
    <div class="tabs">
      <div class="tab-title active" data-tab="1">Условия акции</div>
      <div class="tab-title" data-tab="2">Особенности акции</div>
      <?php if($adeal->video) { ?>
      <div class="tab-title"  data-tab="3">Видео</div> <?php } ?>
      <div class="tab-title"  data-tab="4">Комментарии</div>
      <div class="tab-title"  data-tab="5">О партнере</div>
    </div>

    
    <div class='grid_12 tab tab-active' id="tab1">
      <?php echo $adeal->cond ?>
    </div>
    <div class='grid_12 tab' id="tab2">
      <?php echo $adeal->specs ?>
    </div>

    <div class='grid_12 tab' id="tab3">
      <iframe  width='500' height='320' src='<?php echo $adeal->video ?>' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe>
    </div>

    <div class='grid_6 tab' id="tab5">
      <h2>Номер телефона:</h2>
      <h3><?php echo $adeal->tel ?></h3> <br>
      <h2>Время работы:</h2>
      <h3><?php echo $adeal->time ?></h3> <br>
    </div>

    <div class='grid_12 tab' id="tab4">
      <?php
      $b = false; 
      foreach ($comments as $comment) { 
        if(!$comment->answer) continue;
        $b = true;
      ?>
      <div class="user-comment">

      <?php
        if(!$comment->user_avatar == "") {
      ?>
        <img src="<?php echo $comment->user_avatar ?>" class="user-ava" style="width:100px; height:100px" />
      <?php } 
      else { ?>
        <img src="/images/user_ava.png" class="user-ava" style="width:100px; height:100px" />
      <?php } ?>
        <div class='comment-container'>
          <div class="arrow-left"></div>
          <p class='comment-author'><?php echo $comment->user_name ?></p>
          <p class='comment-text'><?php echo $comment->text ?></p>
        </div> 
      </div>


        <img src="/images/demo_ava.png" class="answerer-ava" style="width:100px; height:100px">
      <div class="answer-comment">
        <div class='comment-container admin-comment'>
          <div class="arrow-right"></div>
          <p class='comment-author'>Ответ</p>
          <p class='comment-text'><?php echo $comment->answer ?></p>
        </div>

      </div>

      <?php } if(!$b) { ?>
      <h4>Комментариев пока нет</h4>
      <?php } ?>
      <div class="clear"></div>
      <h2 style='padding-top:80px clear: both;'>Оставить комментарий</h2>
        <?php //Checking for session
        if(isset($session_name) && $session_name) { ?>
      <div class='leave-comment-container'>
        <form action='/wow/deal/comment/<?php echo $adeal->id ?>' method='post'>
          <textarea class='comment-area' name='text'></textarea>
          <?php 
            foreach ($avatar as $ava) {
          ?>
          <input type="hidden" name="avatar" value="<?php echo $ava->avatar ?>" />
          <?php } ?>
          <input style='margin-top:10px;' type='submit' value='Комментировать' class='btn' />
        </form>
      </div>
       <?php } else ?>
      <h4>Выполните вход, для того, чтобы оставить свой комментарий</h4>
    </div>
  </div>
</div>

<?php include("res/footer.php"); ?>

</body>

  <script defer>

    

    $(function(){
      $('.zoom').zoomy('mouseenter', {border:'6px solid #fff'});

      var currentTab = 1;
      $('.tab-title').click(function(e) {
        $("#tab" + currentTab).hide();
        $(".tab-title").each( function() { $(this).removeClass("active"); } );
        $(this).addClass("active");
        $("#tab" + $(this).data("tab")).show();
        currentTab = $(this).data("tab");
      });
    });

  </script>


</html>
